﻿using Basic.WxCollect;
using Basic.WxRemoteModel.EventMsg;
using Basic.WxRemoteModel.WxMsg.Model;
using Basic.WxService.ConstDic;
using Basic.WxService.Interface;
using WeDonekRpc.Client.Attr;

namespace Basic.WxService.PlatformMsg
{
    [IocName(WxPlatformEventDic.CancelAuthorized)]
    internal class CancelAuthorizedMsgEvent : IWxPlatformMsgEvent
    {
        private readonly IWxPlatformBindCollect _WxPlatformBind;

        public CancelAuthorizedMsgEvent (IWxPlatformBindCollect wxPlatformBind)
        {
            this._WxPlatformBind = wxPlatformBind;
        }

        public void ExecMsg (WxPlatformMsg msg)
        {
            string wxAppId = msg.EventBody["AuthorizerAppid"];
            this._WxPlatformBind.Cancel(msg.PlatformAppId, wxAppId);
            new WxMerBindCancel
            {
                AppId = msg.PlatformAppId,
                WxAppId = wxAppId
            }.Send();
        }
    }
}
